Run command with hidden console
· One min read
Run command without console / hide console window
PowerShell
- This will keep the PowerShell instance running
powershell.exe -WindowStyle Hidden -Command "<command>"
- This will not keep the PowerShell instance running
Start-Process -WindowStyle Hidden "<command>"
Run with shortcut
powershell.exe -Command "Start-Process -WindowStyle Hidden ""<command>"""
WSH
VBS
Create a .vbs
file
run.vbs
CreateObject("WScript.Shell").Exec _
("<command> <arg> ...")
To run the .vbs
file:
# Without console
wscript.exe run.vbs
# With console
cscript.exe run.vbs
JS
Create a .js
file
new ActiveXObject("WScript.Shell").Run("<command> <arg> ...", 0);
run.js
new ActiveXObject("WScript.Shell").Run("cmd /c echo test > text.txt", 0);
To run the .js
file:
# Without console
wscript.exe run.js
# With console
cscript.exe run.js